home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_MNU.TXT < prev    next >
Encoding:
Text File  |  1992-12-22  |  5.8 KB  |  145 lines

  1. '
  2. 'Class description:
  3. '
  4. !short:Mnu class structure:
  5. Class Mnu:
  6. ~~~~~~~~~~~
  7. This class enables to create the simple menu objects, the selecting of
  8. which is done by the cursor arrows or by the stressed character.
  9. (instead of the choice class which doesn't know the stressed characters
  10. but it is processed more quickly)
  11.  
  12. Common use:
  13. ~~~~~~~~~~~
  14. LOCAL OBJECT Mnu OF Mnu
  15. Mnu:Init(...)
  16. n:=Mnu:Process()
  17. Mnu:Done()
  18.  
  19. Due to the heredition can the methods Hide() and Show() of class Win be used
  20. in the class Mnu. It is possible to save temporary the menu and refresh it
  21. and restart the menu selection by repeated call of the Mnu:Process() method.
  22.  
  23. The source code is in the C_Mnu.prg
  24.  
  25. !seealso: c_win.ngo:Win c_box.ngo:Box c_menu.ngo:Menu c_choice.ngo:Choice c_color.ngo:Color ob_class.ngo:"Class hierarchy"
  26.  
  27. !short:~~~~~~~~~~~~~~~~~~~~~
  28. !short:create class Mnu from Win
  29. !short:  export:
  30. !short:  var Help       //{}
  31. ^BMnu:Help^N: public: array
  32.   Paralel array for Mnu:Items, for saving of the "MenuID", which is need for
  33.   the correct detecting of the index (RecNo) for interactive help text
  34.   displaying, for every item from Mnu:Items.
  35.  
  36. !short:  var Items      //{}
  37. ^BMnu:Items^N: public: array
  38.   The array of data, where the items of the text strings to be selected are
  39.   saved. Example:
  40.   {"Choice1","Choice2",...,"ChoiceN"}
  41.  
  42. !short:  var SelItems   //{}
  43. ^BMnu:SelItems^N: public: array
  44.   The paralel array for Mnu:Items, it marks the selectability of the item.
  45.  
  46. !short:  var Cursor     //(object of Cursor)
  47. ^BMnu:Cursor^N: private: object
  48.   Class Cursor object, which stores the cursor shape and position during the
  49.   menu selection.
  50.  
  51. !short:  var Choice     //1
  52. ^BMnu:Choice^N: read-only: numeric
  53.   The current item number of Mnu:Items array is stored here (it was user
  54.   selected). If user instead of item selecting pressed Esc, the negative
  55.   current item number is returned.
  56.  
  57. !short:  var Top        //1
  58. ^BMnu:Top^N: private: numeric
  59.   The first displayed item in the window is stored here. (the menu items can
  60.   scroll in the window). It is need for repeated activation of the method
  61.   Mnu:Process().
  62.  
  63. !short:  var CanAppend  //false
  64. ^BMnu:CanAppend^N: public: logical
  65.   If true, the user can by pressing of Ins/Del keys activate the code block
  66.   which must append/delete some item from Mnu:Items. The menu can be
  67.   dynamicaly changed.
  68.  
  69. !short:  var InsBlock   //{|o|nil}
  70. ^BMnu:InsBlock^N: public: code_block
  71.   This code block is activated from Mnu:Process() only when the Mnu:CanAppend
  72.   is true and when the user pressed the Ins key. As parameter to this code
  73.   block is passed the self object. The task for the code block is to append
  74.   a new item to Mnu:Items(), or to change the instvar variables of this
  75.   object. The menu items can be added/deleted an the menu can be dynamicaly
  76.   changed during of the selection.
  77.  
  78. !short:  var DelBlock   //{|o|nil}
  79. ^BMnu:DelBlock^N: public: code_block
  80.   This code block is activated from Mnu:Process() only when the Mnu:CanAppend
  81.   is true and when the user pressed the Del key. As parameter to this code
  82.   block is passed the self object. The task for the code block is to delete
  83.   an items from  Mnu:Items(), or to change the instvar variables of this
  84.   object. The menu items can be added/deleted an the menu can be dynamicaly
  85.   changed during of the selection.
  86.  
  87. !short:  method New=MnuNew         //o:New() --> self
  88. ^BMnu:New()^N: public: return self
  89.   The object is filled with default values.
  90.  
  91. !short:  method Init=MnuInit       //o:Init(Name,R,C,CurSize,Items,SelItems,Clr,Shd) --> true
  92. ^BMnu:Init(Name,R,C,CurSize,Items,SelItems,Clr,Shadow)^N: public: return true
  93.   This method serves for initialising and positioning of the window for
  94.   the menu to the screen to be nearest as possible to the cursor and
  95.   not to cover the desired text (started on the R,C position with the length
  96.   of CurSize). The window must be whole visible. After the preparing task is
  97.   done, the menu is painted to the screen and the control is returned to the
  98.   calling function.
  99.  
  100.   Parameter description:
  101.   ~~~~~~~~~~~~~~~~~~~~~~
  102.   ^UName^N: text or code block: no default
  103.    Text or code block as window title.
  104.  
  105.   ^UR^N: numeric: default is Row().
  106.    Text -row- (cursor) screen position, which shouldn't be covered,
  107.    but the window should be as near as possible to this text.
  108.  
  109.   ^UC^N: numeric: default is Col().
  110.    Text -column- (cursor) screen position, which shouldn't be covered,
  111.    but the window should be as near as possible to this text.
  112.  
  113.   ^UCurSize^N: numeric: default is 1.
  114.    Text width which shouldn't be covered, but the window should be as near
  115.    as possible to this text.
  116.  
  117.   ^UItems^N: array: no default the data must be entered
  118.    Text strings array, representing the menu.
  119.  
  120.   ^USelItems^N: array: default is the array filled with the true items of
  121.    the same size as the array selected by Items parameter.
  122.    This array enables the menu items selection.
  123.  
  124.   ^UClr^N: character: default is m->Color:Edit.
  125.    Window colors.
  126.  
  127.   ^UShadow^N: logical: default is true for color monitor, false for monochrom.
  128.    If true the shadow is painted around the window.
  129.  
  130. !short:  method Process=MnuProcess //o:Process() --> nChoice
  131. ^BMnu:Process()^N: public: return nChoice
  132.   This method makes the own menu choice, it returns the selected item number,
  133.   if negative, the user instead of the item selecting pressed Esc.(he doesn't
  134.   wanmt to select anything). This method can be called repeatedly, unlimited
  135.   number of times. The data about the selected item is stored to instvar
  136.   variable Mnu:Choice().
  137.  
  138. !short:  method Done=MnuDone       //o:Done() --> true
  139. ^BMnu:Done()^N: public: return true
  140.   The menu is saved, the screen is refreshed and the control is returned to
  141.   calling function.
  142.  
  143. !short:  endclass
  144.  
  145.